package com.webcamtracker.color.segmentation;

import java.awt.image.BufferedImage;
import java.awt.image.BufferedImageOp;
import java.awt.image.ConvolveOp;
import java.awt.image.Kernel;


public class BlurPreProcessor implements PreProcessor {
    public BufferedImage process(BufferedImage image) {


        float[] blurMatrix = {
                1.0f / 9.0f, 1.0f / 8.0f, 1.0f / 9.0f,
                1.0f / 8.0f, 1.0f / 6.0f, 1.0f / 8.0f,
                1.0f / 9.0f, 1.0f / 8.0f, 1.0f / 9.0f
        };

//        	float[] blurMatrix = {
//                    0.0f, -1.0f, 0.0f,
//                    -1.0f, 4.f, -1.0f,
//                    0.0f, -1.0f, 0.0f};


        BufferedImageOp blurFilter;
        blurFilter = new ConvolveOp(new Kernel(3, 3, blurMatrix), ConvolveOp.EDGE_NO_OP, null);
        return blurFilter.filter(image, null);
    }
}
